/**
 * Copyright (C) 2021-2022 maminjie <canpool@163.com>
 * SPDX-License-Identifier: LGPL-2.1
 * Powered by Qt-Advanced-Docking-System
**/

#pragma once

#include "dockfloatingbase.h"

#include <QWidget>

QADS_BEGIN_NAMESPACE

class DockWidget;
class DockPannel;
class DockFloatingDragPreviewPrivate;

/**
 * A floating overlay is a temporary floating widget that is just used to
 * indicate the floating widget movement.
 * This widget is used as a placeholder for drag operations for non-opaque
 * docking
 */
class DockFloatingDragPreview : public QWidget, public DockFloatingInterface
{
    Q_OBJECT
public:
    using Super = QWidget;

    DockFloatingDragPreview(DockWidget *content);
    DockFloatingDragPreview(DockPannel *content);
    ~DockFloatingDragPreview() override;

    void startFloating(const QPoint &dragStartPos, const QSize &size,
                       DragState dragState, QWidget *mouseEventHandler) override;
    void moveFloating() override;
    void finishDragging() override;

signals:
    void draggingCanceled();

protected:
    DockFloatingDragPreview(QWidget *content, QWidget *parent);

protected:
    void paintEvent(QPaintEvent *event) override;
    bool eventFilter(QObject *watched, QEvent *event) override;

private:
    void onApplicationStateChanged(Qt::ApplicationState state);

private:
    DockFloatingDragPreviewPrivate *d;
    friend class DockFloatingDragPreviewPrivate;
}; // class DockFloatingDragPreview

QADS_END_NAMESPACE
